package com.algo.Al.controller;

import com.algo.Al.common.R;
import com.algo.Al.pojo.User;
import com.algo.Al.service.UserService;
import com.algo.Al.service.impl.UserServiceImpl;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: guoxing
 * @Email: gx_study2022@163.com
 * @Description:
 * @Date: 2024/6/3 13:03
 * @ClassName: UserController
 **/
@Log4j
@RestController
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;
    @GetMapping("/{id}")
    public R<User> getUserById(@PathVariable Integer id) {
        User user = userService.getById(id);
        if (user == null) {
            return R.error("查询无果");
        }
        return R.success(user);
    }


}
